# Recipe graphite::mysql

script "Configure mysql for graphite" do
  interpreter "bash"
  user "root"
  code <<-EOF
    mysql -e "CREATE USER 'graphite'@'localhost' IDENTIFIED BY 'complexpassw0rd';" -u root 
    mysql -e "GRANT ALL PRIVILEGES ON graphite.* TO 'graphite'@'localhost';" -u root
    mysql -e "CREATE DATABASE graphite;" -u root
    mysql -e 'FLUSH PRIVILEGES;' -u root 
  EOF
  not_if { ::File.directory?("/var/lib/mysql/graphite") }
end
